package com.boot.mongodb.controller;

import com.boot.mongodb.pojo.User;
import com.boot.mongodb.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.List;

@Slf4j
@Controller
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("users")
    public String users(ModelMap modelmap) {
        List<User> users = this.userService.getUserForPage(2, 10);
        modelmap.addAttribute("users", users);
        return "users";
    }

}
